/*
 * LogowanieGUI.java
 *
 * Created on 3 grudzień 2007, 19:19
 */

package pl.cezary.butler.walili.client.gui;

import pl.cezary.butler.walili.client.LoginControler;

/**
 *
 * @author  neohuman
 */
public class LogowanieGUI extends javax.swing.JPanel {
    
    /** Creates new form LogowanieGUI */
    public LogowanieGUI() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanelHost = new javax.swing.JPanel();
        jLabelHost = new javax.swing.JLabel();
        jTextFieldHost = new javax.swing.JTextField();
        jPanelLog = new javax.swing.JPanel();
        jLabelLogin = new javax.swing.JLabel();
        jTextFieldLogin = new javax.swing.JTextField();
        jLabelHaslo = new javax.swing.JLabel();
        jPasswordFieldHaslo = new javax.swing.JPasswordField();
        jPanelCombo = new javax.swing.JPanel();
        jButtonWyloguj = new javax.swing.JButton();
        jButtonZaloguj = new javax.swing.JButton();
        jCheckBoxRejestrowac = new javax.swing.JCheckBox();

        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("gui"); // NOI18N
        setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("login.title"))); // NOI18N
        setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.PAGE_AXIS));

        jPanelHost.setMaximumSize(new java.awt.Dimension(400, 35));
        jPanelHost.setMinimumSize(new java.awt.Dimension(400, 35));
        jPanelHost.setPreferredSize(new java.awt.Dimension(400, 35));
        jPanelHost.setLayout(new java.awt.GridBagLayout());

        jLabelHost.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelHost.setText(bundle.getString("login.host")); // NOI18N
        jLabelHost.setFocusTraversalPolicyProvider(true);
        jLabelHost.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jLabelHost.setMaximumSize(new java.awt.Dimension(32, 14));
        jLabelHost.setMinimumSize(new java.awt.Dimension(32, 14));
        jLabelHost.setPreferredSize(new java.awt.Dimension(32, 14));
        jPanelHost.add(jLabelHost, new java.awt.GridBagConstraints());

        jTextFieldHost.setMinimumSize(new java.awt.Dimension(215, 20));
        jTextFieldHost.setPreferredSize(new java.awt.Dimension(215, 20));
        jPanelHost.add(jTextFieldHost, new java.awt.GridBagConstraints());

        add(jPanelHost);

        jPanelLog.setMaximumSize(new java.awt.Dimension(400, 35));
        jPanelLog.setMinimumSize(new java.awt.Dimension(400, 35));
        jPanelLog.setPreferredSize(new java.awt.Dimension(400, 35));

        jLabelLogin.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelLogin.setText(bundle.getString("login.username")); // NOI18N
        jLabelLogin.setMaximumSize(new java.awt.Dimension(40, 14));
        jLabelLogin.setMinimumSize(new java.awt.Dimension(40, 14));
        jLabelLogin.setPreferredSize(new java.awt.Dimension(40, 14));
        jPanelLog.add(jLabelLogin);

        jTextFieldLogin.setMinimumSize(new java.awt.Dimension(85, 20));
        jTextFieldLogin.setPreferredSize(new java.awt.Dimension(85, 20));
        jPanelLog.add(jTextFieldLogin);

        jLabelHaslo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelHaslo.setText(bundle.getString("login.password")); // NOI18N
        jLabelHaslo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jLabelHaslo.setMaximumSize(new java.awt.Dimension(80, 14));
        jLabelHaslo.setMinimumSize(new java.awt.Dimension(40, 14));
        jLabelHaslo.setPreferredSize(new java.awt.Dimension(60, 14));
        jPanelLog.add(jLabelHaslo);

        jPasswordFieldHaslo.setMinimumSize(new java.awt.Dimension(85, 20));
        jPasswordFieldHaslo.setPreferredSize(new java.awt.Dimension(85, 20));
        jPanelLog.add(jPasswordFieldHaslo);

        add(jPanelLog);

        jPanelCombo.setMaximumSize(new java.awt.Dimension(400, 35));
        jPanelCombo.setMinimumSize(new java.awt.Dimension(400, 35));
        jPanelCombo.setOpaque(false);
        jPanelCombo.setPreferredSize(new java.awt.Dimension(400, 35));
        jPanelCombo.setLayout(new java.awt.GridBagLayout());

        jButtonWyloguj.setText(bundle.getString("login.logout")); // NOI18N
        jButtonWyloguj.setEnabled(false);
        jPanelCombo.add(jButtonWyloguj, new java.awt.GridBagConstraints());

        jButtonZaloguj.setText(bundle.getString("login.login")); // NOI18N
        jPanelCombo.add(jButtonZaloguj, new java.awt.GridBagConstraints());

        jCheckBoxRejestrowac.setText(bundle.getString("login.do_register")); // NOI18N
        jCheckBoxRejestrowac.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jCheckBoxRejestrowac.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxRejestrowacActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
        jPanelCombo.add(jCheckBoxRejestrowac, gridBagConstraints);

        add(jPanelCombo);
    }// </editor-fold>//GEN-END:initComponents
    
    private boolean rejestruj = false;

    
    private void jCheckBoxRejestrowacActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxRejestrowacActionPerformed
        final String[] opisy={GUI.getLocalized("login.login"),GUI.getLocalized("login.register")};
        rejestruj=!rejestruj;
        
        if(rejestruj){
            jButtonZaloguj.setActionCommand(LoginControler.SIGNIN);
            jButtonZaloguj.setText(opisy[1]);
            jButtonWyloguj.setActionCommand(LoginControler.LOGOUT);
        } else {
            jButtonZaloguj.setActionCommand(LoginControler.LOGIN);
            jButtonZaloguj.setText(opisy[0]);
            jButtonWyloguj.setActionCommand(LoginControler.LOGOUT);
        }        
    }//GEN-LAST:event_jCheckBoxRejestrowacActionPerformed

    private void lokalizuj(){
        jButtonWyloguj.setText(GUI.getLocalized("login.logout"));
        jButtonZaloguj.setText(GUI.getLocalized("login.login"));
        jCheckBoxRejestrowac.setText(GUI.getLocalized("login.do_register"));
        jLabelHaslo.setText(GUI.getLocalized("login.password"));
        jLabelHost.setText(GUI.getLocalized("login.host"));
        jLabelLogin.setText(GUI.getLocalized("login.username"));
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton jButtonWyloguj;
    public javax.swing.JButton jButtonZaloguj;
    public javax.swing.JCheckBox jCheckBoxRejestrowac;
    private javax.swing.JLabel jLabelHaslo;
    private javax.swing.JLabel jLabelHost;
    private javax.swing.JLabel jLabelLogin;
    private javax.swing.JPanel jPanelCombo;
    private javax.swing.JPanel jPanelHost;
    private javax.swing.JPanel jPanelLog;
    public javax.swing.JPasswordField jPasswordFieldHaslo;
    public javax.swing.JTextField jTextFieldHost;
    public javax.swing.JTextField jTextFieldLogin;
    // End of variables declaration//GEN-END:variables
   
}
